package library.user;

import library.BookList;
import library.operation.IOperation;

//所有用户的父类，派生出管理员和用户
public abstract class User {
    //子类可以直接获取到
    protected String name;

    //当前这个类，能够进行那些操作就往这个数组中添加对应的对象
    protected IOperation[] operations;

    public User(String name) {
        this.name = name;
    }

    //显示用户菜单，返回值为用户输入的序号
    public abstract int menu();

    public void work(int choice, BookList bookList) {
        if (choice < 0 || choice >= operations.length) {
            System.out.println("输入的选项非法");
            return;
        }
        operations[choice].work(bookList);
    }
}
